var express = require('express');
var router = express.Router();
const { Category } = require('../models');
const { success, failure } = require('../utils/responses');

/* GET home page. */
router.get('/', async function (req, res, next) {
    try {
        // 查询分类
        const categories = await Category.findAll({
            order: [['rank', 'ASC'],['id', 'DESC']]
        })
        success(
            res, '查询分类成功',
            {categories}
        )
    } catch (error) {
        failure(res, error)
    }
});

module.exports = router;
